<?php

    $con=mysqli_connect('localhost','root','root','test');
    //var_dump($con);
    if($con){
        mysqli_query($con,'set name utf8');
        $sql='select * from login';
        $res=mysqli_query($con,$sql);
        //-> 是获取 $res对象的属性
        if($res->num_rows>0){
            $arr=mysqli_fetch_all($res,MYSQLI_ASSOC);
            print_r($arr);
        }

    }else{
        echo '连接数据库失败';
    }

?>